package com.gitee.aa76111.tdd.args;

import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;

@Getter
@Setter
public class ArgSpec {

    private static final String ARG_DIVIDE = ":";
    private static final int LABEL_INDEX = 0;
    private static final int TYPE_INDEX = 1;
    private static final int TWO = 2;

    private final String label;
    private final String type;

    public ArgSpec(String text) {
        String[] split = text.trim().split(ARG_DIVIDE);
        if (split.length != TWO) {
            throw new IllegalArgumentException("参数结构形式不正确: " + Arrays.toString(split));
        }
        label = split[LABEL_INDEX].trim();
        type = split[TYPE_INDEX].trim();
    }

}
